package car.aistar.service.impl;

import car.aistar.dao.UserCollectDao;
import car.aistar.entity.UserCollect;
import car.aistar.service.UserCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (UserCollect)表服务实现类
 *
 * @author makejava
 * @since 2020-09-30 20:38:34
 */
@Service("userCollectService")
public class UserCollectServiceImpl implements UserCollectService {
    @Autowired
    private UserCollectDao userCollectDao;

    @Override
    public List<UserCollect> findAll (){
        return userCollectDao.findAll();
    }

    @Override
    public List<UserCollect> queryAll(UserCollect userCollect) {
        System.out.println(userCollect);
        return this.userCollectDao.queryAll(userCollect);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserCollect queryById(Long id) {
        return this.userCollectDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserCollect> queryAllByLimit(int offset, int limit) {
        return this.userCollectDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userCollect 实例对象
     * @return 实例对象
     */
    @Override
    public UserCollect insert(UserCollect userCollect) {
        this.userCollectDao.insert(userCollect);
        return userCollect;
    }

    /**
     * 修改数据
     *
     * @param userCollect 实例对象
     * @return 实例对象
     */
    @Override
    public UserCollect update(UserCollect userCollect) {
        this.userCollectDao.update(userCollect);
        return this.queryById(userCollect.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userCollectDao.deleteById(id) > 0;
    }

    /**
    *@Author laoxu
    *@Description //TODO 用户收藏数据删除
    *@Date 7:56 2020/10/5
    *@Param [cId, uId]
    *@return boolean
    **/
    @Override
    public boolean deleteById1(Long cId, Long uId) {

        return this.userCollectDao.deleteById1(cId,uId) > 0;
    }
}